<?php
declare (strict_types=1);

namespace app\course\model\record\admin;

use app\common\model\BaseModel;
use app\course\model\video\admin\VideoSection;
use think\model\concern\SoftDelete;

/**
 * 课程学习记录模型
 */
class LearnCourseRecord extends BaseModel
{
    use SoftDelete;
    /**
     * 表名
     *
     * @var string
     */
    protected $name = 'user_learn_course_record';

    /**
     * 设置自动写入时间
     *
     * @var boolean
     */
    protected $autoWriteTimestamp = true;
    /**
     * 时间显示格式
     *
     * @var string
     */
    protected $dateFormat = 'Y-m-d H:i';
    /**
     * 定义字段类型
     *
     * @var array
     */
    protected $type = [
        'id'          => 'integer'
    ];

    /**
     * 课时信息
     * Author: Martinsun <syh@sunyonghong.com>
     * Date: 2021/9/1
     *
     * @return \think\model\relation\BelongsTo
     */
    public function sectionTitle()
    {
        return $this->belongsTo(VideoSection::class, 'section_id', 'id')->bind(['section_title' => 'title']);
    }
}
